@import '~bootstrap/scss/_functions';
@import '~bootstrap/scss/_variables';
@import "../../base/scss/variables.scss";
@import '~bootstrap/scss/mixins/_breakpoints';

$block-columns: 12;

@mixin block-width($block-width) {
    width: round(percentage($block-width / $block-columns));
}

.dashboard-value-block-wrapper {
    display: flex;
    flex-flow: row wrap;

    @include media-breakpoint-down(xs) {
        padding: 0px 10px;
    }

    .block {
        position: relative;
        display: flex;

        .block-inner {
            width: 100%;
        }
    }
}

.dashboard-other-blocks-wrapper {
    @include media-breakpoint-down(xs) {
        padding: 0px 10px;
    }
}

#dashboard-wrapper {
    position: relative;
}

.block {
    margin-bottom: 10px;
    display: inline-block;
    width: 100%;
    position: absolute;
    padding: 0 5px;

    @include media-breakpoint-up(sm) {
        padding: 0 15px;
    }

    @include media-breakpoint-up(sm) {
        margin-bottom: 30px;
    }

    &.width-small {
        @include block-width(6);

        @include media-breakpoint-up(md) {
            @include block-width(4);
        }

        @include media-breakpoint-up(xl) {
            @include block-width(3);
        }
    }

    &.width-medium {
        @include block-width(12);

        @include media-breakpoint-up(sm) {
            @include block-width(6);
        }
    }

    &.width-large {
        @include block-width(12);

        @include media-breakpoint-up(md) {
            @include block-width(9);
        }
    }

    &.width-full {
        @include block-width(12);
    }

    .block-settings {
        position: absolute;
        top: 13px;
        right: 25px;

        &.open {
            .toggle-settings {
                color: $primary;
            }
        }

        .toggle-settings {
            background: none;
            border: none;
            padding: 3px 7px;
            color: $gray-light;

            &:hover {
                color: $primary;
            }

            i {
                vertical-align: middle;
                text-align: center;
            }
        }

        .dropdown-menu {
            left: auto;
            right: 0;
            border-radius: 0;
            border: 0;
            background: $primary;
            font-size: 0.85em;
            box-shadow: 1px 2px 2px 1px rgba(0, 0, 0, 0.2);

            &:after {
                content: "";
                border-left: 6px solid transparent;
                border-right: 6px solid transparent;
                border-bottom: 6px solid $primary;
                position: absolute;
                top: -6px;
                right: 7px;
            }

            li {
                padding: 0px 10px;

                i {
                    width: 20px;
                    text-align: left;
                }

                a {
                    color: #fff;
                    padding: 3px 0px;

                    &:hover,
                    &:focus,
                    &:active {
                        background: none;
                        text-decoration: underline;
                    }
                }
            }
        }
    }

    .block-inner {
        background-color: $white;
        border-radius: $border-radius;
        box-shadow: $shadow-md;
        display: flex;

        .color-block {
            position: relative;
            width: 100%;

            &::before {
                content: "";
                position: absolute;
                right: 20px;
                left: 20px;
                bottom: -7px;
                height: 10px;
                border-radius: $border-radius;
                z-index: -1;

                @include media-breakpoint-down(xs) {
                    display: none;
                }
            }
        }

        h2,
        .block-title {
            margin: 0;
            padding: 1rem 1.25rem 0 1.25rem;
            font-weight: bold;

            @include media-breakpoint-down(xs) {
                font-size: $h3-font-size;
                padding-left: 1rem;
                padding-right: 1rem;
            }
        }

        .block-subtitle {
            color: $text-muted;
            padding: .25rem 1.25rem .75rem 1.25rem;
            font-weight: 600;

            @include media-breakpoint-down(xs) {
                padding-left: 1rem;
                padding-right: 1rem;
            }
        }

        .block-description {
            color: $text-muted;
            border-top: 2px solid $gray-bg;
            display: block;
            font-size: 0.8rem;
            padding: .75rem 1.25rem;

            @include media-breakpoint-down(xs) {
                padding-left: 1rem;
                padding-right: 1rem;
            }
        }

        .block-content {
            padding: 1rem 1.25rem;

            @include media-breakpoint-down(xs) {
                padding-left: 1rem;
                padding-right: 1rem;
            }
        }

        h2 + .block-content {
            margin-top: 1rem;
            border-top: 2px solid $gray-bg;
        }

        .activity-list,
        .notifications {
            .timestamp {
                padding-left: 10px;
                font-size: 0.9em;
                color: $gray-light;
                text-align: right;
            }

            table {
                width: 100%;
                padding-bottom: 10px;

                td {
                    padding-bottom: 2px;

                    &.dismiss-td {
                        width: 1px;
                        padding-right: 1em;
                    }
                }
            }

            ul {
                list-style: none;
                padding: 0;

                li {
                    display: table;
                    width: 100%;
                    border-bottom: 1px solid #ddd;
                    padding: 10px 5px;

                    &:last-child {
                        border: 0;
                    }
                }

                .timestamp {
                    display: table-cell;
                }

                .activity-name {
                    padding-right: 10px;
                    text-align: left;
                    display: table-cell;
                }
            }

            .dismiss-button {
                background: $success;
                color: #fff;
                padding: 1px 3px;
            }
        }
    }

    // Mixin for changing block header background colors
    @mixin block-bg-color($color) {
        &::before {
            background: rgba($color, .25);
        }
    }

    .block-blue {
        @include block-bg-color($block-blue);
    }
    .block-orange {
        @include block-bg-color($block-orange);
    }
    .block-gray {
        @include block-bg-color($block-gray);
    }
    .block-red {
        @include block-bg-color($block-red);
    }
    .block-purple {
        @include block-bg-color($block-purple);
    }
    .block-green {
        @include block-bg-color($block-green);
    }
    .block-yellow {
        @include block-bg-color($block-yellow);
    }
    .block-navy {
        @include block-bg-color($block-navy);
    }
}

